# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Mike Sampson <mike at sambodata dot com>
# Contributor: Steven <steven at stebalien dot com>
# Contributor: Aaron Griffin <aaron@archlinux.org>
# Contributor: judd <jvinet@zeroflux.org>

pkgname=knockd
pkgver=0.8
pkgrel=1
pkgdesc="A simple port-knocking daemon"
url="http://www.zeroflux.org/projects/knock"
arch=('loong64' 'x86_64')
license=('GPL2')
depends=('libpcap>=1.0.0')
backup=('etc/knockd.conf')
source=(${pkgname}-${pkgver}.tar.gz::http://www.zeroflux.org/proj/knock/files/knock-${pkgver}.tar.gz
        knockd.logrotate
		knockd.service
		limits.h.patch)
sha512sums=('6511e29f604cebc4a4048f5e49c1b73db0bbe0041a88f7c8559fa1a60ea894aadb72a608c423f867a5a4dddb06d00a0713863473981e42273662a77364c260ec'
            '3ea2ae9392d3d79bb5df6b75090f6c1a9548979e01dcd4a75471cfa46dbc70401a166496b5158f90fc61326a554acacc38f8605aab02b5b53b75d60a7d80648a'
            '6e5fec91e07fb74169798f320607bd413258af0af48bd2a9c006a02bc97ce4ea9a5293eb9e166b9870c086bf147fca1462b98b3d914d7a28708e9fa2cc9c85cb'
            '5776b8670aa439e77d5ac873b63dd5e4d4b5bfb8f1e8fbf49c7d0c3c8f97e47dca761ef1374b742182b0d9928dba4b719442c5f01ca29249a6aa6da6cbf283ed')

prepare() {
  cd knock-${pkgver}
  patch -Np0 < "${srcdir}/limits.h.patch"
}

build() {
  cd knock-${pkgver}
  ./configure --prefix=/usr --sbin=/usr/bin --sysconfdir=/etc
  make
}

package() {
  cd knock-${pkgver}
  make DESTDIR="${pkgdir}" MANDIR=/usr/share/man install
  install -Dm 644 "${srcdir}/knockd.service" "${pkgdir}/usr/lib/systemd/system/knockd.service"
  install -Dm 644 "${srcdir}/knockd.logrotate" "${pkgdir}/etc/logrotate.d/knockd"
  install -Dm 644 "README.md" "${pkgdir}/usr/share/doc/${pkgname}/README"
}
